<template>
  <el-dialog v-model="dialogVisible" title="删除用户对话框" width="800" align-center>
    <template #default>
      <span> {{ niceNameArray.join("|") }}</span>
    </template>

    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancelAction()">取消</el-button>
        <el-button type="primary" @click="confrimAction()"> 确认 </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
import axios from "axios";
import { ElMessage } from "element-plus";
export default {
  name: "EditUser",
  components: { ElMessage },
  props: {},
  data() {
    return {
      dialogVisible: false,
      niceNameArray: [],
      userUuidArray: [],
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    cancelAction() {
      this.dialogVisible = false;
    },
    confrimAction() {
      this.dialogVisible = false;
      axios
        .post("/api/user/deleteUserRecycleById", {
          userUuids: this.userUuidArray.join(","),
        })
        .then((data) => {
          //   console.info(`deleteUserRecycleById success:${data.data}`);
          if (data.data.success) {
            ElMessage.success(data.data.msg);
            this.dialogVisible = false;
            this.$bus.emit("queryUserList");
          } else {
            ElMessage.error(data.data.msg);
          }
        })
        .catch(() => {
          ElMessage.error("请联系管理员");
        });
    },
  },
  mounted() {
    let that = this;
    this.$bus.on("deleteDialog", (data) => {
      that.niceNameArray = [];
      that.userUuidArray = [];
      this.dialogVisible = true;
      //   console.info(`data:${JSON.stringify(data)}`);
      data.some((item) => {
        that.niceNameArray.push(item["niceName"]);
        that.userUuidArray.push(item["userUuid"]);
      });
    });
  },
  unmounted() {
    this.$bus.off("deleteDialog");
  },
};
</script>

<style lang="scss"></style>

<style lang="scss" scoped></style>

<style></style>
